package com.rtx.edi.platform.express.config.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rtx.api.annotation.DataSourceAnnotation;
import com.rtx.edi.model.express.po.PlExpressApiConfig;
import com.rtx.edi.platform.express.config.mapper.PlExpressApiConfigMapper;
import com.rtx.edi.platform.express.config.service.PlExpressApiConfigService;

@Service
public class PlExpressApiConfigServiceImpl extends ServiceImpl<PlExpressApiConfigMapper,PlExpressApiConfig> implements PlExpressApiConfigService{

	@DataSourceAnnotation
	@Override
	public List<PlExpressApiConfig> selectList(String datasourceky, LambdaQueryWrapper<PlExpressApiConfig> qw) {
		return baseMapper.selectList(qw);
	}

	@DataSourceAnnotation
	@Override
	public void selectList(Page<PlExpressApiConfig> pageParam, PlExpressApiConfig po) {
        LambdaQueryWrapper<PlExpressApiConfig> query = Wrappers.lambdaQuery();
        query.eq(po.getConfigname() != null,PlExpressApiConfig::getConfigname, po.getConfigname())
                .like(po.getCarriercode() != null, PlExpressApiConfig::getCarriercode, po.getCarriercode())
                .eq(po.getRtxsalesp() != null, PlExpressApiConfig::getRtxsalesp, po.getRtxsalesp())
                .like(po.getStorerkey() != null, PlExpressApiConfig::getStorerkey, po.getStorerkey());
        baseMapper.selectPage(pageParam,query);
	}

	@DataSourceAnnotation
	@Override
	public void addExpressApiConfig(String datasourckey,PlExpressApiConfig dto) {
		baseMapper.insert(dto);
	}
}
